import { WaitTask } from "puppeteer";
import Facade from "../../../framework/base/core/Facade";
import DownloadJson from "../../../framework/base/DownloadJson";
import { AbstractViewModel,Bindable, Command, Model } from "../../../framework/base/mvvm/AbstractViewModel";
import BundleManager from "../../../framework/base/singles/BundleManger";
import Runtime from "../../../framework/base/singles/Runtime";
import SceneManager from "../../../framework/base/singles/SceneManager";
import launch_model from "./launch_model";

@Model(launch_model)
export default class launch_view_model extends AbstractViewModel<launch_model> {
    protected loaded() {
        // this.bind();
    }
    protected unload() {
        
    }
    __progressEventData: number = 0;

    

    public async initLaunch() {
        let runtime = await Runtime.instance.load();
        console.log('runtime',runtime);
        let jsData = await this.model.initData();
        // var isRestart = await this.install()
        // if (isRestart) {
        //     cc.audioEngine.stopAll()
        //     cc.game.restart()
        //      return
        // }
        Facade.getModule('common');
        Facade.getModule('lobby');
        // this.__progressEventData = 0;
        SceneManager.instance.loadScene('lobby', 'lobby', (speed: number, per: number)=>{
            this.progreessEvent(speed,per);
        });
        // this.module.notify.emitModule('lobby', 'scene', 'enter');
        
        
    }

    progreessEvent(speed: number, per: number) {
        console.log('viewm proger',speed, per);
        this.__progressEventData = speed;
    }
    

}

class yuan {
    // @desReturn(false)
    test() {
        console.log(' i m callTest');

    }
}

function desReturn (value:boolean) {
    const f: any = function(target: any, propertyKey: string, descriptor: PropertyDescriptor){
        console.log(Object.getPrototypeOf(target));
        // let name = args[0].prototype.constructor['myname'];
        // if (name == 'it') {
        //     console.log('i m backed');
        //     return;

        // }
        
    }
    return f;
}

type Instantiable<Type> = { new(...params: any[]): Type }
export function PropertyDecoratorex<Type>(type: Instantiable<Type>, property: string) {
    console.log(type);
}
